slacker007
|
Acolyte
|
|
|
Reged: 06/05/04
|
Posts: 119
|
Loc: USA, MS
|
|
|
Does anyone know how I could write a script that makes it impossible to open a door until you have killed all the enimies in the room?
-------------------- --------------------
Cogito ergo sum. -Descartes
(I think therefore I am)
Mediocrity:
It takes alot less time and most people don't notice until its too late
-2004 Dispair Calendar
DON'T CONFORM TO ANTI-CONFORMATISM, JUST BE YOURSELF!
Post Extras:
|
|
|
Lets say there are three enemies in the room, Id's "enemy1, enemy2 and enemy3"
On the door, put this (untested) script
Code:
Begin PB_Lock_in
if ( OnACtivate == 1 ) if ( PB_enemies_dead ) >= 3 ); this is a global variable, or a local variable on a local object, whichever you prefer Activate else Playsound3d "lockeddoor" Messagebox "The door is locked" "OK" endif endif
end
On each of the enemies, which should all have unique IDs
Code:
Begin PB_dead_enemy
short done
if ( done == 0 ) if ( GetHealth <= 0 ) Set PB_enemies_dead to ( PB_enemies_dead + 1 ) Srt done to 1 endif endif
end
Post Extras:
|
slacker007
|
Acolyte
|
|
|
Reged: 06/05/04
|
Posts: 119
|
Loc: USA, MS
|
|
|
Thanks, Patrograd2. I knew someone would come through! Now, I'm creating the test cells right now, but I just wondered, do I have to do anything special to make PB_enemies_dead a variable or does the script that manipulates that variable create it on its own. Thanks.
-------------------- --------------------
Cogito ergo sum. -Descartes
(I think therefore I am)
Mediocrity:
It takes alot less time and most people don't notice until its too late
-2004 Dispair Calendar
DON'T CONFORM TO ANTI-CONFORMATISM, JUST BE YOURSELF!
Post Extras:
|
slacker007
|
Acolyte
|
|
|
Reged: 06/05/04
|
Posts: 119
|
Loc: USA, MS
|
|
|
Also, I'm wanting to make this a chain of cells that once you start going through, you can't go back. It was said that I would need unique id's for each enemy I'm creating that this script pertains to. Does that mean that if I were to make this go through 100 cells(rooms) w/ 4 enimies in each I would have to come up with 400 unique id's, or could I make PB_enimies_dead a local variable and have basically every cell a duplicate of the last.
-------------------- --------------------
Cogito ergo sum. -Descartes
(I think therefore I am)
Mediocrity:
It takes alot less time and most people don't notice until its too late
-2004 Dispair Calendar
DON'T CONFORM TO ANTI-CONFORMATISM, JUST BE YOURSELF!
Post Extras:
|
|
|
To make a global variable go to gameplay->globals, and then select new.
Post Extras:
|
slacker007
|
Acolyte
|
|
|
Reged: 06/05/04
|
Posts: 119
|
Loc: USA, MS
|
|
|
Ok, I've got the variable working, but I'm having trouble with the PB_Dead_Enemy script. On line 6 you have "Srt to 1" but the cs won't accept that. I'm pretty sure that you meant short, and corrected it, but now that i've tested it, I'm not sure if that's what is should have been.
-------------------- --------------------
Cogito ergo sum. -Descartes
(I think therefore I am)
Mediocrity:
It takes alot less time and most people don't notice until its too late
-2004 Dispair Calendar
DON'T CONFORM TO ANTI-CONFORMATISM, JUST BE YOURSELF!
Post Extras:
|
|
|
It should be
Set done to 1
Me and my dodgy typing
Post Extras:
|
slacker007
|
Acolyte
|
|
|
Reged: 06/05/04
|
Posts: 119
|
Loc: USA, MS
|
|
|
There must be a loop or something because I have it set to If () PB_enimies_dead ) >= 4) in the script for the door and I go in and kill 2 and the door opens for me. Don't lines 5 and 6 of PB_dead_enemy do the same thing. If so, every enemy I kill would add 2 to the variable value instead of one.
-------------------- --------------------
Cogito ergo sum. -Descartes
(I think therefore I am)
Mediocrity:
It takes alot less time and most people don't notice until its too late
-2004 Dispair Calendar
DON'T CONFORM TO ANTI-CONFORMATISM, JUST BE YOURSELF!
Post Extras:
|
slacker007
|
Acolyte
|
|
|
Reged: 06/05/04
|
Posts: 119
|
Loc: USA, MS
|
|
|
Come on. A little help here for a scripting noob?
-------------------- --------------------
Cogito ergo sum. -Descartes
(I think therefore I am)
Mediocrity:
It takes alot less time and most people don't notice until its too late
-2004 Dispair Calendar
DON'T CONFORM TO ANTI-CONFORMATISM, JUST BE YOURSELF!
Post Extras:
|
|
|
Line 5 adds 1 to the global variable PB_enemies_dead Line 6 makes sure that this only happens once
I dont know why this is looping (its what line 6 is for), but perhaps one of the other guys can help
Post Extras:
|
Klinn
|
Diviner
|
|
|
Reged: 11/19/02
|
Posts: 2319
|
|
|
|
May I suggest a slightly different approach, which removes the need for the global and updating of it?
Create your own unique-ID version of a creature and put 3 copies of it in the room. The script on the door uses the 'GetDeadCount' function to see if all three have been killed, e.g.:
Begin DoorOutScript If ( OnActivate == 1 ) . . If ( GetDeadCount "Your_Creature_ID" >= 3 ) . . . . Activate . . EndIf EndIf End
If you want more than one type of creature in the room, you could either create two types and expand the script logic slightly to check the GetDeadCount for each, or make a levelled-list-creature to spawn randomly-selected ones within the list.
Hope this helps,
...Klinn
Post Extras:
|